<?php


abstract class BaseCompImagenI18n extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id_imagen = 0;


	
	protected $culture = '';


	
	protected $titulo = '';


	
	protected $comentario;

	
	protected $aCompImagen;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getIdImagen()
	{

		return $this->id_imagen;
	}

	
	public function getCulture()
	{

		return $this->culture;
	}

	
	public function getTitulo()
	{

		return $this->titulo;
	}

	
	public function getComentario()
	{

		return $this->comentario;
	}

	
	public function setIdImagen($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id_imagen !== $v || $v === 0) {
			$this->id_imagen = $v;
			$this->modifiedColumns[] = CompImagenI18nPeer::ID_IMAGEN;
		}

		if ($this->aCompImagen !== null && $this->aCompImagen->getIdImagen() !== $v) {
			$this->aCompImagen = null;
		}

	} 
	
	public function setCulture($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->culture !== $v || $v === '') {
			$this->culture = $v;
			$this->modifiedColumns[] = CompImagenI18nPeer::CULTURE;
		}

	} 
	
	public function setTitulo($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->titulo !== $v || $v === '') {
			$this->titulo = $v;
			$this->modifiedColumns[] = CompImagenI18nPeer::TITULO;
		}

	} 
	
	public function setComentario($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->comentario !== $v) {
			$this->comentario = $v;
			$this->modifiedColumns[] = CompImagenI18nPeer::COMENTARIO;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id_imagen = $rs->getInt($startcol + 0);

			$this->culture = $rs->getString($startcol + 1);

			$this->titulo = $rs->getString($startcol + 2);

			$this->comentario = $rs->getString($startcol + 3);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 4; 
		} catch (Exception $e) {
			throw new PropelException("Error populating CompImagenI18n object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(CompImagenI18nPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			CompImagenI18nPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(CompImagenI18nPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->aCompImagen !== null) {
				if ($this->aCompImagen->isModified() || ($this->aCompImagen->getCulture() && $this->aCompImagen->getCurrentCompImagenI18n()->isModified())) {
					$affectedRows += $this->aCompImagen->save($con);
				}
				$this->setCompImagen($this->aCompImagen);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = CompImagenI18nPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += CompImagenI18nPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aCompImagen !== null) {
				if (!$this->aCompImagen->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aCompImagen->getValidationFailures());
				}
			}


			if (($retval = CompImagenI18nPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = CompImagenI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getIdImagen();
				break;
			case 1:
				return $this->getCulture();
				break;
			case 2:
				return $this->getTitulo();
				break;
			case 3:
				return $this->getComentario();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = CompImagenI18nPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getIdImagen(),
			$keys[1] => $this->getCulture(),
			$keys[2] => $this->getTitulo(),
			$keys[3] => $this->getComentario(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = CompImagenI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setIdImagen($value);
				break;
			case 1:
				$this->setCulture($value);
				break;
			case 2:
				$this->setTitulo($value);
				break;
			case 3:
				$this->setComentario($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = CompImagenI18nPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setIdImagen($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCulture($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setTitulo($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setComentario($arr[$keys[3]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(CompImagenI18nPeer::DATABASE_NAME);

		if ($this->isColumnModified(CompImagenI18nPeer::ID_IMAGEN)) $criteria->add(CompImagenI18nPeer::ID_IMAGEN, $this->id_imagen);
		if ($this->isColumnModified(CompImagenI18nPeer::CULTURE)) $criteria->add(CompImagenI18nPeer::CULTURE, $this->culture);
		if ($this->isColumnModified(CompImagenI18nPeer::TITULO)) $criteria->add(CompImagenI18nPeer::TITULO, $this->titulo);
		if ($this->isColumnModified(CompImagenI18nPeer::COMENTARIO)) $criteria->add(CompImagenI18nPeer::COMENTARIO, $this->comentario);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(CompImagenI18nPeer::DATABASE_NAME);

		$criteria->add(CompImagenI18nPeer::ID_IMAGEN, $this->id_imagen);
		$criteria->add(CompImagenI18nPeer::CULTURE, $this->culture);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		$pks = array();

		$pks[0] = $this->getIdImagen();

		$pks[1] = $this->getCulture();

		return $pks;
	}

	
	public function setPrimaryKey($keys)
	{

		$this->setIdImagen($keys[0]);

		$this->setCulture($keys[1]);

	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setTitulo($this->titulo);

		$copyObj->setComentario($this->comentario);


		$copyObj->setNew(true);

		$copyObj->setIdImagen(''); 
		$copyObj->setCulture(''); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new CompImagenI18nPeer();
		}
		return self::$peer;
	}

	
	public function setCompImagen($v)
	{


		if ($v === null) {
			$this->setIdImagen('');
		} else {
			$this->setIdImagen($v->getIdImagen());
		}


		$this->aCompImagen = $v;
	}


	
	public function getCompImagen($con = null)
	{
		if ($this->aCompImagen === null && ($this->id_imagen !== null)) {
						$this->aCompImagen = CompImagenPeer::retrieveByPK($this->id_imagen, $con);

			
		}
		return $this->aCompImagen;
	}

} 